package com.apps.globals.feedback.service.impl;

import com.apps.globals.feedback.model.po.KupaFeedback;
import com.apps.globals.feedback.dao.KupaFeedbackMapper;
import com.apps.globals.feedback.service.IKupaFeedbackService;
import com.apps.sannotation.constraints.NoNull;
import com.apps.sannotation.constraints.StrLen;
import com.apps.sannotation.keys.JoinKey;
import com.apps.sannotation.keys.TimeLockKey;
import com.apps.saspect.CallTimeLock;
import com.apps.saspect.ThreadLock;
import com.apps.saspect.ValidMethod;
import com.apps.sworld.dao.impl.sDaoImpl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 大鹏
 * @since 2020-11-02
 */
@Service
public class KupaFeedbackServiceImpl extends sDaoImpl<KupaFeedbackMapper, KupaFeedback> implements IKupaFeedbackService {

    @CallTimeLock
    @ThreadLock
    @ValidMethod
    @Override
    public KupaFeedback sendFeedBack(Integer member_id,
                                     @TimeLockKey  @JoinKey @StrLen (min = 4,max = 20,errMsg = "联系方式最少4个字,最多20字") @NoNull(errMsg = "联系方式不能为空") String contact,
                                     @TimeLockKey  @JoinKey @StrLen (min = 10,max = 200,errMsg = "反馈内容最少10个字,最多200字")  @NoNull(errMsg = "反馈内容不能为空") String context)
    {
        KupaFeedback feedback=new KupaFeedback();
        feedback.setMember_id(null != member_id?member_id:-1);
        feedback.setContact(contact);
        feedback.setContext(context);
        return saveToDB(feedback);
    }
}
